{
  open Parser;;
  open Algo;;
  open String;;
  
  (* Colonne courante dans le tableau *)
  let col = ref 0;;
  
  let first_info_col = 4;;
  
  let current_dir = ref "/" ;;
  
  exception PolicySyntaxError of string;;
}

rule lexer = parse
  | eof
      {
	Leof
      }
  | ','
      {
	col := !col + 1;
	lexer lexbuf
      }
  |  '"''/'[^'\n''"']*':''"'
      {
	current_dir := (String.sub (Lexing.lexeme lexbuf) 1 ((String.length (Lexing.lexeme lexbuf)) - 3));
	Lpath(!current_dir)
      }
  | '\n'
      {
	col := 0;
	Leol
      }
  | ('0' | (['1'-'9']['0'-'9']*))
      {
	match !col with
	    0 -> LContainerId (int_of_string(Lexing.lexeme lexbuf))
	  | _ -> raise (PolicySyntaxError ("An unexpected integer was encountered at column " ^ string_of_int(!col)))
      }
  | '"'[^'\n''"'',']*[^':']'"'
      {
	if (!col >= first_info_col) then
	  LInfo (Data(!col - first_info_col))
	else
	  let matched_string = Lexing.lexeme lexbuf in
	  let file_name = String.sub matched_string 1 ((String.length matched_string) - 2) in
	  LContainerInfo (!current_dir ^ "/" ^ file_name)
      }
  | _ 
    {
      lexer lexbuf
    }

